package com.zhx.experiment.service;

import com.zhx.experiment.mapper.UserMapper;
import com.zhx.experiment.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public void addUser(User user){
        userMapper.insertUser(user);
    }

    //查询所有User
    public List<User> findAllUser() {
        return userMapper.findAll();
    }

    //根据name删除User
    public void deleteUserByName(String name) {
        userMapper.deleteUser(name);
    }

    //根据name查询User
    public User queryUserByName(String username) {
        return userMapper.queryUser(username);
    }

    //登录
    public User loginUser(User user){
        return userMapper.loginUser(user.getUsername(),user.getPassword());
    }

    //修改User
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
}
